package 常用方法.String对象的比较.与compareTo方式相同但是忽略大小写比较;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 姚东名
 * Date: 2024-06-20
 * Time: 11:24
 */
//int compareToIgnoreCase(String str) 方法：与compareTo方式相同，但是忽略大小写比较
public class Test {
    public static void main(String[] args) {
        String s1 = new String("abc");
        String s2 = new String("ac");
        String s3 = new String("ABc");//忽略大小写 -> abc
        String s4 = new String("abcs");

        System.out.println(s1.compareToIgnoreCase(s2));//不同输出字符差值为-1
        System.out.println(s1.compareToIgnoreCase(s3));//相同输出0
        System.out.println(s1.compareToIgnoreCase(s4));//前k个字符完全相同，输出长度差值-1
    }
}
